package com.wy.controller;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wy.controller.dto.PetAuxiliaryCheckDTO;
import com.wy.entity.AttributeExam;
import com.wy.service.IAuxiliaryCheckService;
import org.apache.commons.lang.StringUtils;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wy.common.R;

import com.wy.service.IPetAuxiliaryCheckService;
import com.wy.entity.PetAuxiliaryCheck;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 宠物辅助检查明细表 前端控制器
 * </p>
 *
 * @author 王昭贵
 * @since 2023-04-20
 */
@RestController
@RequestMapping("/pet-auxiliary-check")
public class PetAuxiliaryCheckController {

    @Resource
    private IPetAuxiliaryCheckService petAuxiliaryCheckService;

    @Resource
    private IAuxiliaryCheckService auxiliaryCheckService;

    /*****
     * 前台--用户获取宠物历史检查记录列表
     * @param customerId
     * @return
     */
    @GetMapping("/petauxiliaryaxam")
    public R getPetAuxiliaryAxam(@RequestParam int customerId) {
        List<PetAuxiliaryCheckDTO> petAuxiliaryCheckFrontPage = petAuxiliaryCheckService.
                getPetAuxiliaryCheckFrontPage(customerId);
        return R.success(petAuxiliaryCheckFrontPage);
    }

    @PostMapping("/beginCheck")
    public R beginCheck(@RequestBody int id){
        PetAuxiliaryCheck petAuxiliaryCheck = petAuxiliaryCheckService.getById(id);
        petAuxiliaryCheck.setStatus(2);
        petAuxiliaryCheckService.updateById(petAuxiliaryCheck);
        return R.success("");
    }


    /****
     * 后台 辅助检查记录分页
     * @param page
     * @param pageSize
     * @return
     */
    @GetMapping("/page")
    public R findPage(@RequestParam String name,@RequestParam Integer page,
                                @RequestParam Integer pageSize) {
        Page<PetAuxiliaryCheck> pageList;
        pageList = petAuxiliaryCheckService.getPetAuxiliaryCheckPage(new Page<>(page,pageSize),name);
        return R.success(pageList);
    }

}

